package com.derbysoft.ota.interfaces.ws.hotel;

import com.derbysoft.ota.application.service.HotelSearchService;
import com.derbysoft.ota.application.service.StagingService;
import com.derbysoft.ota.domain.server.ServerType;
import com.derbysoft.ota.interfaces.protocol._2009a.OTAHotelSearchRQ;
import com.derbysoft.ota.interfaces.ws.AbstractEndpoint;

public class HotelSearchEndpoint extends AbstractEndpoint {

    private HotelSearchService hotelSearchService;

    public HotelSearchEndpoint(ServerType serverType, StagingService stagingService, HotelSearchService hotelSearchService) {
        super(serverType, stagingService);
    	this.hotelSearchService = hotelSearchService;
    }

    @Override
    protected Object invokeInternal(Object requestObject) throws Exception {
		OTAHotelSearchRQ hotelSearchRQ = (OTAHotelSearchRQ) requestObject;
		if (serverType.isStaging()) {
			return stagingService.search(hotelSearchRQ);
		}
		return hotelSearchService.search(hotelSearchRQ);
    }
}
